<template>
	<view>
		<view class="cu-bar tabbar bg-white foot">
			<view @tap="jumpHome()" class="action" :class=" 'text-' + [tabCur==1?tintColor:'gray']">
				<view class="cuIcon-home"></view> 首页
			</view>
			<view @tap="jumpCircle()" class="action" :class=" 'text-' + [tabCur==2?tintColor:'gray']">
				<view class="cuIcon-discover"></view> 圈子
			</view>
			<view class="action text-gray add-action">
				<button :class="'cu-btn cuIcon-add shadow '+themeColor" @click="create()"></button>
				发布
			</view>
			<view @tap="jumpMessage()" class="action" :class=" 'text-' + [tabCur==3?tintColor:'gray']">
				<view class="cuIcon-message">
					<view v-if="unreadMsgCount>0" class="cu-tag badge">{{unreadMsgCount}}</view>
				</view> 消息
			</view>
			<view @tap="jumpMy()" class="action" :class=" 'text-' + [tabCur==4?tintColor:'gray']">
				<view class="cuIcon-my">
					<view v-if="unreadCount>0" class="cu-tag badge">{{unreadCount}}</view>
				</view>
				我的
			</view>
		</view>
	</view>
</template>

<script>
	import {checkLogin} from '@/js_sdk/checkLogin.js'
	import {isLogin} from '@/api/auth.js'
	export default {
		name:"tabbar",
		data() {
			return {
				tintColor:this.ThemeTintColor,
				themeColor:this.ThemeColor
			};
		},
		props: {
			tabCur: {
				type: Number,
				default: 1
			},
			unreadCount: {
				type: Number,
				default: 0
			},
			unreadMsgCount: {
				type: Number,
				default: 0
			}
		},
		methods: {
			jumpMy() 
			{
				uni.switchTab({
				    url: '/pages/my/my'
				});
			},
			jumpCircle()
			{
				uni.switchTab({
				    url: '/pages/circle/circle'
				});
			},
			jumpHome() {
				uni.switchTab({  
				    url: '/pages/index/index' 
				});
			},
			jumpMessage()
			{
				uni.switchTab({
				    url: '/pages/message/message'
				});
			},
			create(){
				//是否登陆
				if(isLogin() == false) {
					checkLogin()
					return;
				}
				this.$emit('publish')
			}
		},
	}
</script>

<style lang="scss">

</style>
